﻿@using System.Web.UI.WebControls
@using dotnethost.Watermark.Models
@using System.Drawing.Text
@model WatermarkFont
@{
    ViewBag.Title = "Watermark Creator";
    var fontStyleItems = from WatermarkFont.Style e in Enum.GetValues(typeof(WatermarkFont.Style))
                         select e;
    var horizontalAlignItems = from WatermarkFont.HAlign e in Enum.GetValues(typeof(WatermarkFont.HAlign))
                               select e;
    var verticalAlignItems = from WatermarkFont.VAlign e in Enum.GetValues(typeof(WatermarkFont.VAlign))
                               select e;
    var fontFamilyList = new InstalledFontCollection();
}
@section headScript
{
 <script src="@Url.Content("~/Scripts/watermark/watermark.js")" type="text/javascript"></script>
 <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
}

<h2>Watermark Creator</h2>
@using (Html.BeginForm("Result", "Watermark", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.ValidationSummary(true) 
    <fieldset>
    <div class="editor-label">
    <label for="image">Upload your image:</label>
    </div>
    <div class="field-validation-error" id="imageErr"></div>
    <div class="editor-field">

    <input type="file" name="image" onchange="checkFileType(this)"/>
    </div>
    <div class="editor-label">
    <label for ="watermark">write your watermark:</label>
    </div>
    <div class="field-validation-error" id="waterMarkTextErr"></div>
    <div class="editor-field">
    <input type="text" name="watermark" onchange="checkWatermarkText(this)" />
    </div>
    <div class="editor-label">
    @Html.LabelFor(model => model.FontColor)
    </div>
    <div class="editor-field">
    @Html.EditorFor(model => model.FontColor)
    @Html.ValidationMessageFor(model => model.FontColor)
    </div>
        <div class="editor-label">
    @Html.LabelFor(model => model.FontSize)
    </div>
    <div class="editor-field">
    @Html.EditorFor(model => model.FontSize)
    </div>
        <div class="editor-label">
    @Html.LabelFor(model => model.FontFamily)
    </div>
    <div class="editor-field">
    @Html.DropDownListFor(model => model.FontFamily,new SelectList(fontFamilyList.Families.Select<System.Drawing.FontFamily,string>(f=>f.Name)))
    </div>
        <div class="editor-label">
    @Html.LabelFor(model => model.FontStyle)
    </div>
    <div class="editor-field">
    @Html.DropDownListFor(model => model.FontStyle, new SelectList(fontStyleItems))
    </div>
        <div class="editor-label">
    @Html.LabelFor(model => model.HorizontalAlign)
    </div>
    <div class="editor-field">
    @Html.DropDownListFor(model=>model.HorizontalAlign,new SelectList(horizontalAlignItems))
    </div>
    <div class="editor-label">
    @Html.LabelFor(model => model.VerticalAlign)
    </div>
    <div class="editor-field">
    @Html.DropDownListFor(model => model.VerticalAlign,new SelectList(verticalAlignItems))
    @Html.ValidationMessageFor(model => model.VerticalAlign)
    </div>
    <div class="editor-label">
    @Html.LabelFor(model => model.Opacity)
    </div>
    <div class="editor-field">
    @Html.EditorFor(model => model.Opacity)
    @Html.ValidationMessageFor(model=>model.Opacity)
    </div>
    <div class="editor-label">
    @Html.LabelFor(model => model.Padding)
    </div>
    <div class="editor-field">
    @Html.EditorFor(model => model.Padding)
    @Html.ValidationMessageFor(model => model.Padding)
    </div>
    <p>
    <input type="submit" value="submit" />
    </p>
    </fieldset>
}
